import fetch from 'utils/fetch'

// 教师列表
export function getTeachers(data) {
  return fetch({
    url: '/user/famous/',
    methods: 'get',
    params: data
  })
}

// 教师详情
export function getTeacherInfo(data) {
  return fetch({
    url: '/user/famous/info/',
    methods: 'get',
    params: data
  })
}

// 名师讲堂
export function getForums(data) {
  return fetch({
    url: '/user/famous/forum/',
    method: 'get',
    params: data
  })
}

// 名师课程
export function getTeacherCourse(data) {
  return fetch({
    url: '/user/famous/course/',
    method: 'get',
    params: data
  })
}

// 购买名师课程
export function buyCourse(data) {
  return fetch({
    url: '/user/buy/course/',
    method: 'post',
    data,
    transformRequest: [function(data) {
      // Do whatever you want to transform the data
      let ret = ''
      for (const it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}